<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta charset="utf-8">
<title>SMM撮合系统</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css">

<link href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css" id="style_components" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/css/plugins.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/layout.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color">
<link href="${request.getContextPath()}/Public/assets/admin/css/custom.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css">

<link href="${request.getContextPath()}/Public/assets/admin/css/common.css" rel="stylesheet" type="text/css">

<link rel="shortcut icon" href="${request.getContextPath()}/Public/favicon.ico">
<script>BASE_URL = '${request.getContextPath()}'</script>
<link href="${request.getContextPath()}/Public/css/customerDetail.css" rel="stylesheet" type="text/css">
<style>

</style>
</head>

<body class="page-header-top-fixed">
<!--头部信息结束 -->
<div class="page-header">
	<!--头部开始-->
	<#include "/include/top.html" />
	<!-- 头部信息结束 -->


	<!-- 头部菜单开始 -->
	<#include "/include/top_menu.html" />
	<!-- 头部菜单结束 -->
</div>
<!-- END HEADER -->


<!-- BEGIN PAGE CONTAINER -->
<div class="page-container">
	<!-- 内容开始 -->
	<div class="page-content">
		<div class="container-fluid">
			<!-- 当前位置提示结束 -->
			<div class="row margin-top-10">
				<!--位置提示结束  -->
				<div class="col-md-12">
				     <div class="portlet light bordered">
					    <div class="portlet-body">
						
		<form  id="frm1" >
						<div class="row">
							<h1>编辑订单</h1>
							
							<table class="table table-striped table-bordered table-advance table-hover" >
								<thead>
											<tr>
												<th>产品</th>
												<th>计量单位</th>
												<th>数量</th>
												<th>单位/元</th>
											</tr>
								</thead>	
								<tbody>
							<#list list as m>	
							<input type="hidden" name="subId" value="${m.subId?c}"/>
								<tr>
									<td>
										<select id="itemId">
												<option>${m.product?if_exists}</option>
										</select>
									</td>
									<td>
										<select name="unit">
												<option value="0"  <#if m.unit?? && m.unit==0>selected</#if>>吨</option>
												<option value="1"  <#if m.unit?? && m.unit==1>selected</#if>>千克</option>
										</select>
									</td>	
									<td>
										<input type="text" name="quantity" id="quantity" value="${m.quantity?string("#.##")}"/>
									</td>
									<td><input type="text" name="price" id="price" value="${m.price?string("#.##")}"/></td>
								</tr>
						</#list>
								</tbody>
							</table>
						<br>
						<br>
						<table class="tb" cellspacing="1" border="1">
						<input type="hidden" name="orderId" value="${map.id?string("#.##")}"/>
						<input type="hidden" name="itemId"  value="${map.itemid?string("#.##")}"/>
						
							<tr>
									<td class="tdTitle">卖方</td>
									<td class="tdContent">
									<select name="sellId" id="sellId">
											<#list companylist as company>
												<option value="${company.id?c}" 
													<#if  map.sellId?number==company.id>
														selected="selected"
													</#if>
												>${company.name?if_exists}</option>
											</#list>
										</select>
									<td class="tdTitle">买方</td>
									<td class="tdContent">
									<select name="buyId" id="buyId">
										   <#list companylist as company>
												<option value="${company.id?c}" 
													<#if  map.buyId?number==company.id>
														selected="selected"
													</#if>
												>${company.name?if_exists}</option>
											</#list>
										</select>
									</td>
								</tr>
								<tr>
								<td class="tdTitle">省份仓库</td>
									<td class="tdContent">
										<select name="ware_province" id="ware_province" onchange="selWareName(this.value);">
											<#list areas as area>
												<option value="${area.id?c}" 
													<#if  area.id==map.areaid?number>
														selected="selected"
													</#if>
												>${area.name?if_exists}</option>
											</#list>
										</select>
										-
									<select name="ware_name" id="wareName">
						    			<option value="-1">请选择仓库</option>
						    		</select>
									</td>
									<td class="tdTitle" >交货日期</td>
									<td class="tdContent">
										<input name="deliveryDateStr" value="${map.deliveryDate?if_exists}"  class="Wdate" type="text" readonly="readonly" id="hts" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
									</td>
								</tr>
								<tr>
									<td class="tdTitle" >磅差</td>
									<td class="tdContent"><input type="text" name="poundDiff" id="poundDiff" value="${map.poundDiff?if_exists}"/></td>
									<td class="tdTitle">交货方式</td>
									<td class="tdContent">
										<label><input type="radio" id="delivery" name="delivery" value="0"
										<#if map.delivery==0>checked="checked"</#if>
										>款到发货 </label>
										<label><input type="radio" id="delivery" name="delivery" value="1"
										<#if map.delivery==1>checked="checked"</#if>
										>货到付款</label>
									</td>
								</tr>
								<tr>
									<td class="tdTitle">结算方式</td>	
									<td class="tdContent">
										<label><input type="radio" name="payment" id="payment" value="0"
										<#if map.payment==0>checked="checked"</#if>/>现汇 </label>
										<label><input type="radio" name="payment" id="payment2" value="1"
											<#if map.payment==1>checked="checked"</#if> />承兑(三月)</label>
										<label><input type="radio" name="payment" id="payment3" value="2" <#if map.payment==2>checked="checked"</#if>/>承兑(六月)</label>
									</td>
									<td class="tdContent">
									&nbsp;
									</td>
									<td class="tdContent">
									&nbsp;
									</td>
								</tr>
						</table>
						<div style="margin:0 auto; width:100%;margin-top: 20px;text-align: center;">
								<a class="btn green" onclick="orderSave()" >保存</a>&nbsp;
								<a class="btn green" onclick="javascript :history.back(-1);">返回</a>
							</div>
						</div>
					</form>

						    </div>
					    </div>
					</div>
				</div>
			</div>
		</div>
</div>



<!-- END PAGE CONTAINER -->



<!-- 底部开始 -->
<#include "/include/foot.html" />
<!-- 底部结束 -->

<!--[if lt IE 9]>
<script src="${request.getContextPath()}/Public/assets/global/plugins/respond.min.js"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/excanvas.min.js"></script> 
<![endif]-->
<script src="${request.getContextPath()}/Public/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.sparkline.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/admin/scripts/indexComponent.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function() {
	   Metronic.init(); // init metronic core componets
	   Layout.init(); // init layout
	   selWareName("${map.areaid?if_exists}");
	});

	//保存订单
	 function orderSave(){
		$.ajax({
			url : "${request.getContextPath()}/order/orderSave.do",
			type : "post",
			dataType:"json",
			async: false,
			data : $("#frm1").serialize(),
			success : function(result) {
			   if(result.code=="success"){
				   CommonUtils.succModal("系统提示", "保存成功！");
				   window.location="${request.getContextPath()}/order/ordersList.do";
				}else {
					CommonUtils.succModal("系统提示", result.message);
		   		}
			   }
			});
	} 
	

	

	function selWareName(value){
		if(value==-1){
			var ops =  document.getElementById("wareName").options;
			ops.length=0;
			ops.add(new Option("请选择仓库","-1"));
			return;
		}
		$.ajax({
			url : "${request.getContextPath()}/buyOrder/selWarehouseByArea.do",
			type : "post",
			dataType:"json",
			async: false,
			data :{"areaId":value},
			success : function(result) {
				var ops =  document.getElementById("wareName").options;
				ops.length=0;
				if(result["list"].length>0){
					for(var i=0;i<result["list"].length;i++){
						ops.add(new Option(result["list"][i]["name"],result["list"][i]["name"]));					
					}
				}else{
					ops.add(new Option("请选择仓库","-1"));
				}
			}
		});
	}
</script>

</body>
</html>